package com.shenghui.enterprise.enterprise.front.controller;

import com.shenghui.enterprise.enterprise.front.service.IFrontLoginService;
import com.shenghui.enterprise.utils.GeneralUtil;
import com.shenghui.enterprise.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/front/login")
public class LoginController {

    @Autowired
    private IFrontLoginService frontLoginService;

    /**
     * 登录方法
     * @param request
     * @param account
     * @param password
     * @return
     */
    @RequestMapping("/login")
    public Result login(HttpServletRequest request, String account, String password){
        if(GeneralUtil.isNull(account)){
            return Result.error("登录账号不能为空!");
        }
        if(GeneralUtil.isNull(password)){
            return Result.error("密码不能为空!");
        }
        return frontLoginService.login(request,account,password);
    }

    /**
     * 退出登录
     * @param request
     * @return
     */
    @RequestMapping("/loginOut")
    public Result loginOut(HttpServletRequest request){
        return frontLoginService.loginOut(request);
    }
}
